package com.vcolco.skill;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

public class Singleton {
    private volatile static Singleton uniqueSingleton;
    private volatile Set<String> redisKey = null;
    private volatile SimpleDateFormat yyyyMMddHHmmss = null;

    private Singleton() {
        redisKey = new HashSet<>();
        yyyyMMddHHmmss = new SimpleDateFormat("yyyyMMddHHmmss");
    }

    public static Singleton getInstance() {
        if (null == uniqueSingleton) {
            synchronized (Singleton.class) {
                if (null == uniqueSingleton) {
                    uniqueSingleton = new Singleton();
                }
            }
        }
        return uniqueSingleton;
    }

    public boolean setkey(String key){
        return this.redisKey.add(key);
    }

    public String getTime(){
        return yyyyMMddHHmmss.format(new Date());
    }
}
